import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int left=0,max=0;
        for(left=0;left<arr.length;left++){
            int right=arr.length-1;
            while(left!=right){
                if(arr[right]-arr[left]>max){
                    max=arr[right]-arr[left];
                }
                right--;
            }
        }
        System.out.println(max);
    }
}